#pragma once

#include <vector>
#include <filesystem>
#include "SimpleIni.h"
#include "charconv.hpp"

namespace fs = std::filesystem;

typedef std::map<std::string, std::string> StringMap;


class CTrHelper
{
public:

	inline static std::string Appath()
	{
		return fs::current_path().string();
	}

	inline static std::map<std::string, std::string> loadConfigMap(const char* path, const char* keyname)
	{
		StringMap mpVal;
		fs::path mapfile(path);
		if (fs::exists(mapfile))
		{
			CSimpleIniA ini;
			if (SI_OK == ini.LoadFile(path))
			{
				CSimpleIniA::TNamesDepend keys;
				ini.GetAllKeys(keyname, keys);
				for (const auto& it : keys) {
					mpVal.insert(std::pair<std::string, std::string>(it.pItem, UTF8toChar(ini.GetValue(keyname, it.pItem, ""))));
				}
				return mpVal;
			}
		}
		std::cerr << mapfile.string() << " not exist" << "\n";
		return mpVal;		
	}
};